// Copyright (c) Appeon. All rights reserved.
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. 
// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

namespace SnapObjects.Data
{
    /// <summary>
    ///     Represents an object used to build a HAVING clause of a SQL statement.
    ///     The HAVING clause specifies the search condition for a group or an aggregate.
    /// </summary>
    public interface ISqlHavingBuilder : ISqlOrderBuilder
    {
        /// <summary>
        ///     Creates a HAVING clause, and adds a search condition to the HAVING clause. You can specify 
        ///     a SQL expression on the left the operator and a specific value on the right of the operator. The operator is '='.
        /// </summary>
        /// <param name="left">An expression on the left of the operator.</param>
        /// <param name="value">
        ///     The specific value on the right of the operator.
        /// </param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr HavingValue(string left, object value);

        /// <summary>
        ///     Creates a HAVING clause, and adds a search condition to the HAVING clause. You can specify the SQL 
        ///     expression on the left the operator and a specific value on the right of the operator.
        /// </summary>
        /// <param name="left">An expression on the left of the operator.</param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator which is the operator to test the expression on the left and the value on the right.
        /// </param>
        /// <param name="value">
        ///     The specific value on the right of the operator.
        /// </param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr HavingValue(string left, SqlBinaryOperator sqlOperator, object value);

        /// <summary>
        ///     Creates a HAVING clause, and adds a search condition to the HAVING clause. You can specify a SQL 
        ///     expression on the left of the operator and a SQL parameter on the right of the operator. The operator is '='.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="parameter">
        ///     An ISqlParameter object which represents a SQL parameter on the right of the operator. 
        ///     It can be created by calling the SqlBuilder.Parameter method.
        /// </param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr Having(string left, ISqlParameter parameter);

        /// <summary>
        ///     Creates a HAVING clause and adds a search condition to the HAVING clause. You can specify a SQL expression 
        ///     on the left of the operator and a SQL parameter on the right of the operator.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator, which is the operator to test the two expressions on the left and right.
        /// </param>
        /// <param name="parameter">
        ///     An ISqlParameter object which represents a SQL parameter on the right of the operator. 
        ///     It can be created by calling the SqlBuilder.Parameter method.
        /// </param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr Having(string left, SqlBinaryOperator sqlOperator, ISqlParameter parameter);

        /// <summary>
        ///     Creates a HAVING clause and adds a search condition to the HAVING clause. You can specify SQL expressions
        ///     on both the left and right of the operator. The operator is '='.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="right">A SQL expression on the right of the operator.</param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr Having(string left, string right);

        /// <summary>
        ///     Creates a HAVING clause and adds a search condition to the HAVING clause. You can specify SQL expressions 
        ///     on both the left and right of the operator.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator, which is the operator to test the two expressions on the left and right.
        /// </param>
        /// <param name="right">A SQL expression on the right of the operator.</param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr Having(string left, SqlBinaryOperator sqlOperator, string right);

        /// <summary>
        ///     Creates a HAVING clause and adds a search condition to the HAVING clause. You can specify a SQL expression on the 
        ///     left of the operator and a SQL subquery on the right side. The operator is '='.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="sqlBuilder">An ISqlBuilder object which represents a SQL subquery on the right of the operator.</param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr Having(string left, ISqlBuilder sqlBuilder);

        /// <summary>
        ///     Creates a HAVING clause and adds a search condition to the HAVING clause. You can specify a SQL expression on the 
        ///     left of the operator and a SQL subquery on the right side.
        /// </summary>
        /// <param name="left">A SQL expression on the left of the operator.</param>
        /// <param name="sqlOperator">
        ///     An enumeration value of SqlBinaryOperator which is the operator to test the two expressions on the left and right.
        /// </param>
        /// <param name="sqlBuilder">An ISqlBuilder object which represents a SQL subquery on the right of the operator.</param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr Having(string left, SqlBinaryOperator sqlOperator, ISqlBuilder sqlBuilder);

        /// <summary>
        ///     Creates a HAVING clause, and adds a search condition to the HAVING clause by an ISqlHavingCondition object.
        /// </summary>
        /// <param name="condition">
        ///     An ISqlHavingCondition object which represents a search condition in the HAVING clause.
        ///     This object can be created by using the SqlBuilder.Having method and so on.
        /// </param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr Having(ISqlHavingCondition condition);

        /// <summary>
        ///     Creates a HAVING clause, and adds a search condition to the HAVING clause by an ISqlHavingCondition 
        ///     object and specifies the name for the search condition.
        /// </summary>
        /// <param name="condition">
        ///     An ISqlHavingCondition object which represents a search condition in the HAVING clause.
        ///     This object can be created by using the SqlBuilder.Having method and so on.
        /// </param>
        /// <param name="havingName">The name for the search condition.</param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr Having(ISqlHavingCondition condition, string havingName);

        /// <summary>
        ///     Creates a HAVING clause and adds a raw SQL to the HAVING clause.
        /// </summary>
        /// <param name="havingClause">A string of raw SQL to be added to the HAVING clause.</param>
        /// <param name="parameters">
        ///     (Optional) An array of ISqlParameter objects which define the SQL parameters used in the raw SQL.
        /// </param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr HavingRaw(string havingClause, params ISqlParameter[] parameters);

        /// <summary>
        ///     Creates a HAVING clause, and adds a raw SQL to the HAVING clause and specifies a name for the raw SQL.
        /// </summary>
        /// <param name="havingClause">A string of raw SQL to be added to the HAVING clause.</param>
        /// <param name="havingName">The name for the raw SQL.</param>
        /// <param name="parameters">
        ///     (Optional) An array of ISqlParameter objects which define the SQL parameters used in the raw SQL.
        /// </param>
        /// <returns>
        ///     Returns the ISqlHavingAndOr object which can be used to add more search conditions to the current HAVING clause.
        /// </returns>
        ISqlHavingAndOr HavingRaw(string havingClause, string havingName, params ISqlParameter[] parameters);

        /// <summary>
        ///     Returns an ISqlOrderThenBuilder object which can be used to add sorting criteria to the ORDER clause.
        /// </summary>
        /// <returns>
        ///     Returns an ISqlOrderThenBuilder object which can be used to add sorting criteria to the ORDER clause.
        /// </returns>
        ISqlOrderThenBuilder AsOrderBy();
    }
}
